package com.by.wx.process.msg;

import com.by.wx.redis.RedisManage;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @Author 陈子杰
 * @Description
 * @Version 1.0.0
 * @Date 2025/4/16 16:52
 */
@Slf4j
@Service("cXProcessFactory")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class CXProcessFactory implements MessageProcessor {
    private final RedisManage redisManage;

    @Override
    public void processor(String message) {
        String regex = "亚万登记：([^-]+)-(\\d+\\.\\d+)";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(message);
        if (matcher.find()) {
            String name = matcher.group(1);
            String date = matcher.group(2);
            redisManage.set("亚万登记:" + date + ":" + name, name);
        }
    }
}
